import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import spring_annotation.config.MainAutowiredConfig;
import spring_annotation.dao.BookDao;
import spring_annotation.pojo.Boss;
import spring_annotation.pojo.Car;
import spring_annotation.pojo.Color;
import spring_annotation.service.BookService;

public class IOCTest_Autowired {

    ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainAutowiredConfig.class);

    @Test
    public void test01(){
        BookService bookService = applicationContext.getBean(BookService.class);
        System.out.println(bookService);
        BookDao bookDao = (BookDao) applicationContext.getBean("bookDao");
        System.out.println(bookDao);
        ((AnnotationConfigApplicationContext) applicationContext).close();
    }

    @Test
    public void test02(){
        Boss boss = applicationContext.getBean(Boss.class);
        System.out.println(boss);
        Car car = applicationContext.getBean(Car.class);
        System.out.println(car);
        Color color = applicationContext.getBean(Color.class);
        System.out.println(color);
        ((AnnotationConfigApplicationContext) applicationContext).close();
    }


}
